﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Skybound.Gecko;

namespace FrameDisplayServer.Browser
{
    public partial class BrowserForm : Form
    {        
     
        public BrowserForm()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);          
        }
        
        public virtual void Navigate(string url)
        {                      
        }

        public void ShowWindow()
        {
            this.WindowState = FormWindowState.Normal;

            Screen screen = this.FindTargetScreen();
            this.Bounds = screen.Bounds;

            this.BringToFront();
        }

        private Screen FindTargetScreen()
        {
            string targetScreen = AppCentral.SettingsManager.BrowserTargetScreenDeviceName;
            if (String.IsNullOrEmpty(targetScreen))
            {
                return Screen.PrimaryScreen;
            }

            Screen[] screens = Screen.AllScreens;
            foreach (Screen screen in screens)
            {
                if (screen.DeviceName == targetScreen)
                {
                    return screen;
                }
            }

            return Screen.PrimaryScreen;
        }       

        
    }
}
